package org.example.demoblg.serviser;

import org.example.demoblg.mapper.BlogInfo;
import org.example.demoblg.model.Blog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServicerBlog {
    @Autowired
    private BlogInfo blogInfo;
//    获取博客列表
    public List<Blog> getBlogList() {
        List<Blog> blogs =blogInfo.getAll();
        return blogs;

    }
//    通过id获取博客详情
    public Blog getBlog(Integer id) {
        Blog blog = blogInfo.getById(id);
        return blog;
    }
//    删除博客
    public Integer deleteBlog(Integer id) {
        Integer result= blogInfo.deleteById(id);
        return result;
    }
//    编辑博客
    public Integer updateBlog(Blog blog) {
        Integer result= blogInfo.update(blog);

        return result;
    }
//    添加博客
    public Integer addBlog(Blog blog) {
        int result=0;
        result=blogInfo.insert(blog);
        return result;
    }
}
